
@extends ('layouts/app')

@section('content')
    <div class="weui-pay append">
        <form action="" id="info" name="info">
            @csrf
            <div class="site weui-cells_checkbox">
                <div class="weui-cell ">
                    <div class="weui-cell__hd">
                        <label for="cardno">身份证号:</label>
                    </div>
                    <div class="weui-cell__bd">
                        <input type="text"  class="weui-input" name="cardno" placeholder="">
                    </div>
                </div>
            </div>
            <div class="site weui-cells_checkbox">
                <div class="weui-cell ">
                    <div class="weui-cell__hd">
                        <label for="realname">真实姓名:</label>
                    </div>
                    <div class="weui-cell__bd">
                        <input type="text"  class="weui-input" name="realname" placeholder="">
                    </div>
                </div>
            </div>


            <div class="demos-content-padded">
                <a href="javascript:;" class="weui-btn weui-btn_blue open-popup">确认</a>
            </div>
        </form>
    </div>
    {{--已认证--}}
    <div class="weui-pay is-realname">
        <a href="" class="js_grid">
            <div class="weui-grid__icon kbanpng">
                <img src="/img/kban.png" alt="">
            </div>
            <h2 class="weui-grid__label gary9 f30">
                您已认证!
            </h2>
        </a>
    </div>
    <script>

        function getTousers(){
        $.post("/api/user/checkIdentify","#info",function(res){
            if (typeof res === 'string'){
                res =JSON.parse(res);
            }
            if(res.code === 201){
               $(".is-realname").hide();
            }else{
                $(".append").hide();
            }
            //console.log("res", res);
            //history.go(-1);

        });
        }
        getTousers();




        // 点击确认
        $(".open-popup").click(function () {
            var cardno = $("input[name='cardno']").val(),
                realname = $("input[name='realname']").val();

            // 简单的验证身份证号
            var cinfo = InputStrategy.check("isCardNo", cardno);

            if (cinfo) {
                return $.toast(cinfo, "text");
            }

            // 简单的验证名字
            var rinfo = InputStrategy.check("isUserName", realname);

            if (rinfo) {
                return $.toast(rinfo, "text");
            }


            save("/api/user/identify", "#info", function (res) {
                if (typeof res === 'string') {
                    res = JSON.parse(res);
                }

                $.alert(res.info, function () {
                    if (res.code == 200) {
                       history.back();
                    }
                });
            });
        });

//        /api/user/identify
//        参数：	cardno  身份证号
//        realname	真实姓名
//        token （小程序专用）
    </script>
@endsection
